package netty.study.first;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName TestServerInitializer.java
 * @Description TODO
 * @createTime 2020年04月10日 14:57:00
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
	//管道建立的时候调用
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		//HttpServerCodec合并了 HttpRequestDecoder, HttpResponseEncoder
		pipeline.addLast("httpServerCodec",new HttpServerCodec());
		pipeline.addLast("testHttpServerHandler",new TestHttpServerHandler());
	}
}
